package cn.com.cennavi.test;

import java.util.HashMap;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import cn.com.cennavi.bean.DiDiOrignalBean;

/**
 * 滴滴标准答案匹配到link上
 * 
 * @ClassName: LaneStandardAnswerDataMatching
 * @Description: TODO（这里用一句话描述这个类的作用）
 * @author bull
 * @date 2016年7月13日 下午3:08:06
 *
 */
public class LaneStandardAnswerDataMatching {

	private static final String didiStandardFile = "D:\\data\\滴滴分车道路况标准答案\\201606\\20160621加密后.csv";
	/**地图编译文件，有两个，一个是封闭道路的分歧点路口信息，一个是地面道路十字路口信息**/
	/**封闭道路分歧点路口配置文件**/
	private static final String mapCompileFile="D:\\data\\DifPointTotalMapInfo.csv";
	private static final String outFile = "D:\\data\\滴滴分车道路况标准答案\\201606\\20160621加密后匹配到封闭道路上位置.csv";

	/**封闭道路分歧点路口配置文件**/
//	private static final String mapCompileFile="D:\\data\\DifPointTotalMapInfo.csv";
//	private static final String outFile = "D:\\data\\滴滴分车道路况标准答案\\201606\\20160621加密后匹配到地面道路上位置.csv";

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
	}
	public class didiStatardData{
		public String id;
		public String timeStamp;
		public double lat;
		public double lon;
		public double speed;//kmph
		public int Altitude;//海拔米
		public didiStatardData parseData(String line){
			String [] arr=line.split(",");
			if(arr.length!=7){
				return null;
			}
			didiStatardData didi=new didiStatardData();
			didi.id=arr[0];
			didi.timeStamp=arr[1]+" "+arr[2];
			didi.lat=Double.parseDouble(arr[3]);
			didi.lon=Double.parseDouble(arr[4]);
			didi.speed=Double.parseDouble(arr[5]);
			didi.Altitude=Integer.parseInt(arr[6]);
			return didi;
		}
		
	}
	public class DidiQueueService{
		private  HashMap<String, BlockingQueue<DiDiOrignalBean>> didiQueueMap = new HashMap<>();

		/**
		 * 把数据加载到缓存区域，每个carid最多缓存bufferPointNum个点
		 * 
		 * @return
		 */
		public  void putDataToQueueMap(DiDiOrignalBean didi, int bufferPointNum) {

			String key = didi.carID;
			BlockingQueue<DiDiOrignalBean> queue = didiQueueMap.get(key);
			if (queue == null) {
				BlockingQueue<DiDiOrignalBean> queue1 = new ArrayBlockingQueue<>(bufferPointNum);
				queue1.add(didi);
				didiQueueMap.put(key, queue1);
			} else {
				if (queue.size() < bufferPointNum) {
					queue.add(didi);
				} else {
					queue.poll();
					queue.add(didi);
				}

			}
		}

		public  HashMap<String, BlockingQueue<DiDiOrignalBean>> getDidiCacheMap() {
			return didiQueueMap;
		}
	}

}
